


import com.model.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.beans.usercofiguration.UserConfiguration;
import com.beans.usercomponent.UserComponent;
import com.beans.usercontoller.*;
import com.beans.userrepository.UserRepository;
import com.beans.userservice.UserService;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.beans.Introspector;

/**
 * 启动类
 */
public class App {
    public static void main(String[] args) {
        //1.获取Spring上下文
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");


        //2.得到bean
//        UserController userController=context.getBean(UserController.class);
//        //3.使用bean
//        userController.sayHi("java");

//        UserService userService = context.getBean("userService", UserService.class);
//        userService.sayHi("javaee");

//        UserRepository userRepository = context.getBean("userRepository", UserRepository.class);
//        userRepository.sayHello("世界");

//        UserComponent userComponent = context.getBean("userComponent", UserComponent.class);
//        userComponent.sayHello("world");

//        UserConfiguration userConfiguration = context.getBean("userConfiguration", UserConfiguration.class);
//        userConfiguration.sayHello("world");

//        USController usController = context.getBean("USController", USController.class);
//        usController.sayHi();

        //JAVA中bean的命名规则
//        String className="USerController";
//        System.out.println( Introspector.decapitalize(className));


//        User user1=context.getBean("user1",User.class);
//        System.out.println(user1);

//        UserController userController = context.getBean("userController",UserController.class);
//        System.out.println(userController.getUserId(10));

//        UserController2 userController2 = context.getBean("userController2",UserController2.class);
//        System.out.println(userController2.getUserId(11));

//        UserController3 userController3 = context.getBean("userController3",UserController3.class);
//        System.out.println(userController3.getUserId(12));

//        UserController4 userController4 = context.getBean("userController4",UserController4.class);
//        System.out.println(userController4.getUserId(13));

//        UserController5 userController5 = context.getBean("userController5",UserController5.class);
//        System.out.println(userController5.getUserId(14));

//        UserController6 userController6 = context.getBean("userController6", UserController6.class);
//        userController6.sayHi();

//        UserController7 userController7 = context.getBean("userController7",UserController7.class);
//        System.out.println(userController7.getUser());

        UserController8 usController8=context.getBean(UserController8.class);
        User user=usController8.getUser();
        System.out.println(user);
        UserController9 usController9=context.getBean(UserController9.class);
        System.out.println(usController9.getUser());

    }
}
